package com.lmq.funcPro;

/**
 * Method References refer to methods without
 * the extra baggage required by previous version of java.
 * It is a class name or an object name, followed by a ::,
 * then the name of the method.
 */

import java.util.*;
import java.util.function.Consumer;

interface Callable {
    void call(String s);
}

class Describe {
    void show(String msg) {
        System.out.println(msg);
    }
}


public class MethodReferences {
    static void hello(String name) {
        System.out.println("Hello, " + name);
    }
    static class Description {
        String about;
        Description(String desc) { about = desc; }
        void help(String msg) {
            System.out.println(about + " " + msg);
        }
    }

    static class Helper {
        static void assit(String msg) {
            System.out.println(msg);
        }
    }

    public static void main(String[] args) {
        Describe d = new Describe();
        Callable c = d::show;
        c.call("call()");

        c = MethodReferences::hello;
        c.call("Bob");


        c = new Description("valuable")::help;
        c.call("information");


        Callable assit = Helper::assit;
        assit.call("Help!");

    }
}
